package io.github.cunyu1943;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Package : io.github.cunyu1943
 * @ClassName : Square.java
 * @CreateTime : 2022/11/27 22:14
 * @Version : 1.0
 * @Author : 村雨遥
 * @Email : 747731461@qq.com
 * @公众号 : 村雨遥
 * @Website : https://cunyu1943.github.io/JavaPark
 * @Description : 求平方根
 */
public class Square {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("输入一个整数");
        int num = scanner.nextInt();

        for (int i = 1; i <= num; i++) {
            if (num == i * i) {
                System.out.println(num + " 的平方根是: " + i);
                break;
            } else if (num < i * i) {
                System.out.println(num + " 的平方根是: " + (i - 1));
                break;
            }
        }
    }
}
